// VS_BEGIN
#version 330 core
layout (location = 0) in vec3 aPos;

uniform mat4 u_model;
uniform float u_size;
uniform float u_gap;
uniform int u_type;

layout (std140) uniform EngineUBO
{
    mat4 u_view;
    mat4 u_project;
    vec3 u_camPos;
};

void main() {
    vec3 pos;
    if (u_type == 0) {
        if (gl_VertexID == 0) {
            pos = vec3(0.0f, -u_size * 0.5f, 0.0f);
        } else {
            pos = vec3(0.0f, u_size * 0.5f, 0.0f);
        }
        pos.x = -u_size * 0.5f;
        pos.x += gl_InstanceID * u_gap;
    } else {
        if (gl_VertexID == 0) {
            pos = vec3(-u_size * 0.5f, 0.0f, 0.0f);
        } else {
            pos = vec3(u_size * 0.5f, 0.0f, 0.0f);
        }
        pos.y = -u_size * 0.5f;
        pos.y += gl_InstanceID * u_gap;
    }
    gl_Position = u_project * u_view * u_model * vec4(pos, 1.0f);
}
// VS_END

// FS_BEGIN
#version 330 core

out vec4 FragColor;

uniform vec4 u_color;

void main() {
    FragColor = u_color;
}
// FS_END